home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
emulator
/
bsvc-1.000
/
bsvc-1
/
bsvc-1.0.4
/
src
/
SimHector
/
loader
/
Loader.cxx
next >
Wrap
C/C++ Source or Header
|
1995-07-26
|
2KB
|
69 lines
/////////////////////////////////////////////////////////////////////////////// //
//
// Loader.cxx
//
// By: Bradford W. Mott
// November 5,1993
//
///////////////////////////////////////////////////////////////////////////////
#include <iostream.h>
#include <fstream.h>
#include "BasicCPU.hxx"
#include "Tools.hxx"
#include "Loader.hxx"
///////////////////////////////////////////////////////////////////////////////
// Load the named file into the address space
///////////////////////////////////////////////////////////////////////////////
String Loader::Load(const char* filename, int space)
{
String error;
// Open the file for reading
fstream file(filename, ios::in);
// Make sure the file was opened
if(file.bad())
{
error="ERROR: Could not open file!!!";
return(error);
}
error=LoadHectorObjectFile(file,space);
return(error);
}
///////////////////////////////////////////////////////////////////////////////
// Load in a Hector object file into an address space
///////////////////////////////////////////////////////////////////////////////
String Loader::LoadHectorObjectFile(fstream& file,int space)
{
unsigned long address;
String line;
int t,length,byte;
while(1)
{
file >> line;
if(file.eof())
break;
if((line.length()<9) || (line[4]!='/'))
return("ERROR: Incorrect file format!!!");
address=StringToInt(line(0,4)) * CPU()->Granularity();
line.del(0,5);
length=line.length()/2;
for(t=0;t<length;++t)
{
byte=StringToInt(line(0,2));
line.del(0,2);
CPU()->address_space[space].Poke(address+t,(unsigned char)byte);
}
}
return("");
}